package com.liuyuan.service.impl;

import com.liuyuan.mapper.UserDao;
import com.liuyuan.pojo.User;
import com.liuyuan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User getUserById(int id) {
//        User user = new User();
//        user.setId(id);
//        user.setUsername("zhangsan");
//        user.setPassword("123456");
//        System.out.println(user.getId());
//        System.out.println(user.getUsername());
//        return user;
//        if(id>0)
        User user=userDao.getUserById(id);
       return user;
    }

    @Override
    public List<User> getAllUser() {
        return userDao.getAllUser();
    }

    @Override
    public int addUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return userDao.deleteUser(id);
    }
}
